package com.zhbg.controller;

import com.zhbg.pojo.User;
import com.zhbg.service.UserService;
import com.zhbg.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 
 * 时间 2024/08/14
 */
@RestController
@CrossOrigin
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    @PostMapping("/login")
    public SysResult login(@RequestBody User user){//登录方法，json串用@RequestBody接
        System.out.println("账户:"+user.getUsername()+"密码:"+user.getPassword());
        String token = userService.login(user);
        if(token==null){
            return SysResult.faill();
        }
        return SysResult.success(token);
    }

}
